package com.zry.study.mvp.presenter

import android.content.Context
import android.content.Intent
import android.view.View
import android.widget.Toast
import com.zry.study.R
import com.zry.study.bean.User
import com.zry.study.databinding.ActivityMainBinding
import com.zry.study.mvp.model.DataBandingUserInfo
import com.zry.study.mvp.model.OnUserInfoListener
import com.zry.study.ui.activity.LoginActivity

class MainPresenter(private var context: Context, private var mainBinding: ActivityMainBinding) {
	
	fun getUserInfo(what: Int, mobile: String) {
		
		
		DataBandingUserInfo().getLoginUser(mobile, object : OnUserInfoListener<User.UserInfo> {
			override fun getUserInfoSuccess(bena: User.UserInfo) {
				mainBinding.userInfo = bena
			}
			
			override fun getUserInfoFailed(errorCode: Any) {
				Toast.makeText(context, "请求失败", Toast.LENGTH_SHORT).show()
			}
			
		})
	}
	
	
	fun handleClick(view: View) {
		when (view.id) {
			R.id.userName -> {
				Toast.makeText(view.context, "小明", Toast.LENGTH_SHORT).show()
			}
			R.id.userPass -> {
				Toast.makeText(view.context, "小红", Toast.LENGTH_SHORT).show()
			}
			R.id.userSex -> {
				Toast.makeText(view.context, "小强", Toast.LENGTH_SHORT).show()
			}
			R.id.userLogin -> {
				val intent = Intent(context, LoginActivity::class.java)
				context.startActivity(intent)
			}
		}
	}
}